package com.sxtyxt.online.file;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.sxtyxt.adapter.ViewHolderListAdapter;
import com.sxtyxt.entity.MailFile;
import com.sxtyxt.online.R;

/**
 * 分类列表适配器
 *
 * @author General
 */

public class SendFileListAdapter extends ViewHolderListAdapter<MailFile, SendFileListAdapter.ClassifyHolder> {

    private Context context;

    /**
     * @param context
     */
    public SendFileListAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    protected void findView(View convertView, ClassifyHolder holder, MailFile item) {
        holder.txtNumber = (TextView) convertView.findViewById(R.id.txt_number);
        holder.txtBeginPlace = (TextView) convertView.findViewById(R.id.txt_begin_place);
        holder.txtEndPlace = (TextView) convertView.findViewById(R.id.txt_end_place);
        holder.txtSender = (TextView) convertView.findViewById(R.id.txt_sender);
        holder.txtReceiver = (TextView) convertView.findViewById(R.id.txt_receiver);
    }

    @Override
    protected View getConvertView(MailFile item, LayoutInflater mInflater, int position) {
        return mInflater.inflate(R.layout.file_list_item_send, null);
    }

    @Override
    protected ClassifyHolder getHolder() {
        return new ClassifyHolder();
    }

    @Override
    public int getCount() {
        int count = getListData().size();
        return count;
    }

    @Override
    protected void refreshView(final int position, MailFile item, View convertView, ClassifyHolder holder) {
        holder.txtNumber.setText(getUnNullString(item.getLogisticsId(), ""));
        holder.txtBeginPlace.setText(getUnNullString(item.getStartAddress(), ""));
        holder.txtEndPlace.setText(getUnNullString(item.getEndAddress(), ""));
        holder.txtSender.setText(getUnNullString(item.getSnapShootStartPerson(), ""));
        holder.txtReceiver.setText(getUnNullString(item.getSnapShootEndPerson(), ""));
    }



    class ClassifyHolder {
        public TextView txtNumber, txtBeginPlace, txtEndPlace, txtSender, txtReceiver;
    }
}


